package androidx.preference;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.Checkable;
import android.widget.CompoundButton;
import b.f.d.c.g;

public class CheckBoxPreference extends TwoStatePreference {
    private final a V;

    private class a implements CompoundButton.OnCheckedChangeListener {
        a() {
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            if (!CheckBoxPreference.this.b(Boolean.valueOf(z))) {
                compoundButton.setChecked(!z);
            } else {
                CheckBoxPreference.this.G0(z);
            }
        }
    }

    public CheckBoxPreference(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, g.a(context, m.checkBoxPreferenceStyle, 16842895));
    }

    public CheckBoxPreference(Context context, AttributeSet attributeSet, int i) {
        this(context, attributeSet, i, 0);
    }

    public CheckBoxPreference(Context context, AttributeSet attributeSet, int i, int i2) {
        super(context, attributeSet, i, i2);
        this.V = new a();
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, t.CheckBoxPreference, i, i2);
        J0(g.o(obtainStyledAttributes, t.CheckBoxPreference_summaryOn, t.CheckBoxPreference_android_summaryOn));
        I0(g.o(obtainStyledAttributes, t.CheckBoxPreference_summaryOff, t.CheckBoxPreference_android_summaryOff));
        H0(g.b(obtainStyledAttributes, t.CheckBoxPreference_disableDependentsState, t.CheckBoxPreference_android_disableDependentsState, false));
        obtainStyledAttributes.recycle();
    }

    private void M0(View view) {
        boolean z = view instanceof CompoundButton;
        if (z) {
            ((CompoundButton) view).setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) null);
        }
        if (view instanceof Checkable) {
            ((Checkable) view).setChecked(this.Q);
        }
        if (z) {
            ((CompoundButton) view).setOnCheckedChangeListener(this.V);
        }
    }

    private void N0(View view) {
        if (((AccessibilityManager) i().getSystemService("accessibility")).isEnabled()) {
            M0(view.findViewById(16908289));
            K0(view.findViewById(16908304));
        }
    }

    public void P(l lVar) {
        super.P(lVar);
        M0(lVar.M(16908289));
        L0(lVar);
    }

    /* access modifiers changed from: protected */
    public void c0(View view) {
        super.c0(view);
        N0(view);
    }
}
